//
//  RootViewController.m
//  指纹识别
//
//  Created by lzy on 2018/4/20.
//  Copyright © 2018年 lzy. All rights reserved.
//

#import "RootViewController.h"
#import "ViewController.h"
#import "CustomTitleViewController.h"
#import "TitleLableViewController.h"
#import "RunTimeViewController.h"
#import "CustomTextViewController.h"
#import "CountDownViewController.h"
#import "ThreadSafetyViewController.h"
@interface RootViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic , strong) UITableView * table;
@property (nonatomic , strong) NSArray *dataArray;
@end

@implementation RootViewController
-(UITableView *)table{
    if (!_table) {
        _table = [[UITableView alloc]initWithFrame:CGRectMake(0, 64, self.view.bounds.size.width, self.view.bounds.size.height)];
        _table.delegate = self;
        _table.dataSource = self;
        _table.rowHeight = 44;
    }
    return _table;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"demo";
    
    
    
    // Do any additional setup after loading the view.
}
-(void)viewWillAppear:(BOOL)animated
{
    self.dataArray = @[@"指纹识别>>",@"自定义字体>>",@"行间距修改>>",@"runtime机制>>",@"自定义TextView>>",@"倒计时>>",@"线程安全>>"];
    if (_table) {
        self.table.hidden = NO;
    }else{
        [self.view addSubview:self.table];
    }
}
-(void)viewWillDisappear:(BOOL)animated{
    if (_table) {
        self.table.hidden = YES;
    }
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell * cell = [[UITableViewCell alloc]init];
    cell.textLabel.text = self.dataArray[indexPath.row];
    cell.textLabel.textColor = [UIColor blueColor];
    return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        [self.navigationController pushViewController:[ViewController new] animated:NO];
    }else if(indexPath.row == 1){
        [self.navigationController pushViewController:[CustomTitleViewController new] animated:NO];
    }else if(indexPath.row == 2){
        [self.navigationController pushViewController:[TitleLableViewController new] animated:NO];
    }else if(indexPath.row == 3){
        [self.navigationController pushViewController:[RunTimeViewController new] animated:NO];
    }else if(indexPath.row == 4){
        [self.navigationController pushViewController:[CustomTextViewController new] animated:NO];
    }else if(indexPath.row == 5){
        [self.navigationController pushViewController:[CountDownViewController new] animated:NO];
    }else if(indexPath.row == 6){
        [self.navigationController pushViewController:[ThreadSafetyViewController new] animated:NO];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}






@end
